package com.anne.fish.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

@Entity
@Table(name="ip_address",catalog="fish")
@Searchable
@XmlRootElement
public class IpAddress extends BaseObject implements Serializable {
    private Long id;
    private Long startIp;
    private Long endIp;
    private String province;
    private String isp;
    private String startIpStr;
    private String endIpStr;

    @Id  @SearchableId    
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    @Column(name="start_ip", nullable=false)
    @SearchableProperty
    public Long getStartIp() {
        return this.startIp;
    }
    
    public void setStartIp(Long startIp) {
        this.startIp = startIp;
    }
    
    @Column(name="end_ip", nullable=false)
    @SearchableProperty
    public Long getEndIp() {
        return this.endIp;
    }
    
    public void setEndIp(Long endIp) {
        this.endIp = endIp;
    }
    
    @Column(name="province", length=50)
    @SearchableProperty
    public String getProvince() {
        return this.province;
    }
    
    public void setProvince(String province) {
        this.province = province;
    }
    
    @Column(name="isp", length=50)
    @SearchableProperty
    public String getIsp() {
        return this.isp;
    }
    
    public void setIsp(String isp) {
        this.isp = isp;
    }
    
    @Column(name="start_ip_str", nullable=false, length=50)
    @SearchableProperty
    public String getStartIpStr() {
        return this.startIpStr;
    }
    
    public void setStartIpStr(String startIpStr) {
        this.startIpStr = startIpStr;
    }
    
    @Column(name="end_ip_str", nullable=false, length=50)
    @SearchableProperty
    public String getEndIpStr() {
        return this.endIpStr;
    }
    
    public void setEndIpStr(String endIpStr) {
        this.endIpStr = endIpStr;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        IpAddress pojo = (IpAddress) o;

        if (startIp != null ? !startIp.equals(pojo.startIp) : pojo.startIp != null) return false;
        if (endIp != null ? !endIp.equals(pojo.endIp) : pojo.endIp != null) return false;
        if (province != null ? !province.equals(pojo.province) : pojo.province != null) return false;
        if (isp != null ? !isp.equals(pojo.isp) : pojo.isp != null) return false;
        if (startIpStr != null ? !startIpStr.equals(pojo.startIpStr) : pojo.startIpStr != null) return false;
        if (endIpStr != null ? !endIpStr.equals(pojo.endIpStr) : pojo.endIpStr != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (startIp != null ? startIp.hashCode() : 0);
        result = 31 * result + (endIp != null ? endIp.hashCode() : 0);
        result = 31 * result + (province != null ? province.hashCode() : 0);
        result = 31 * result + (isp != null ? isp.hashCode() : 0);
        result = 31 * result + (startIpStr != null ? startIpStr.hashCode() : 0);
        result = 31 * result + (endIpStr != null ? endIpStr.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("id").append("='").append(getId()).append("', ");
        sb.append("startIp").append("='").append(getStartIp()).append("', ");
        sb.append("endIp").append("='").append(getEndIp()).append("', ");
        sb.append("province").append("='").append(getProvince()).append("', ");
        sb.append("isp").append("='").append(getIsp()).append("', ");
        sb.append("startIpStr").append("='").append(getStartIpStr()).append("', ");
        sb.append("endIpStr").append("='").append(getEndIpStr()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
